textlayout: Only special case selection rendering for opaque colors
authorAlexander Mikhaylenko <alexm@gnome.org>
Mon, 3 May 2021 14:03:47 +0000 (19:03 +0500)
committerAlexander Mikhaylenko <alexm@gnome.org>
Mon, 3 May 2021 19:16:05 +0000 (00:16 +0500)
If the selection is partially transparent, it may still be desirable to
see the colors from tags underneath.

gtk/gtktextlayout.c

index d127c489b2e7e6e4c5a79f2cbd6b6411c322bb7d..b31c70799e489a1ca16fa09df1da7568fbb6c9e8 100644 (file)
@@ -3873,8 +3873,12 @@ render_para (GskPangoRenderer   *crenderer,
       if (at_last_line)
         selection_height += line_display->bottom_margin;
 
+      /* Don't draw the text underneath if the whole line is selected. We can
+       * only do it if the selection is opaque.
+       */
       if (selection_start_index < byte_offset &&
-          selection_end_index > line->length + byte_offset) /* All selected */
+          selection_end_index > line->length + byte_offset &&
+          selection->alpha >= 1)
         {
           gtk_snapshot_append_color (crenderer->snapshot,
                                      selection,